﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CorporationWars
{
    [Serializable]
    public class StockEntity
    {
        public string StockName { get; set; }
        public int Stocks { get; set; }
        public decimal BuyPrice { get; set; }
        public decimal SellPrice { get; set; }
        /// <summary>
        /// Can only be sold after this date..
        /// </summary>
        public string DateRestricted { get; set; }

        public decimal Value
        {
            get { return Stocks * BuyPrice; }
        }

        public StockEntity(string name, int cnt, decimal price, string dateRestriction, decimal sellPrice = 0)
        {
            StockName = name;
            Stocks = cnt;
            BuyPrice = price;
            DateRestricted = dateRestriction;
            SellPrice = sellPrice;
        }

        public static bool operator ==(StockEntity a, StockEntity b)
        {
            bool retVal = false;

            if (a.BuyPrice == b.BuyPrice && a.DateRestricted == b.DateRestricted && a.StockName == b.StockName)
                retVal = true;

            return retVal;
        }
        public static bool operator !=(StockEntity a, StockEntity b)
        {
            bool retVal = false;

            if (a.BuyPrice != b.BuyPrice && a.DateRestricted != b.DateRestricted && a.StockName != b.StockName)
                retVal = true;

            return retVal;
        }
    }
}
